import {Map,List,fromJS} from 'immutable';

export default (state = Map(), action) => {

  if (action.type === 'TERM_LIST') {
    return state.set('termlist',List(action.termlist));
  }

  if (action.type === 'TREM_ADD') {
    return state.update('termlist',value=>{
      return value.unshift(action.info)
    });
  }

  if (action.type === 'TERM_EDIT') {
    return state.update('termlist',value=>{
      return value.update(action.index,value=>{
        return action.info
      })
    });
  }

  if (action.type === 'TERM_DELETE') {
    return state.update('termlist',value=>{
      return value.delete(action.index)
    });
  }

  return state;
};